'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {};
//条码主档
modelField.BarcodeMaster = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster',
    Name: '条码主档',
    IsUnique: true,
};
//条码
modelField.Barcode = {
    type: String,
    trim: true
};
//入库业务类型，0:生产完工，1: 交接区入库，2：采购收货
modelField.RcvBusinessType = {
    type: Number
};
//业务单据ID
modelField.BusinessDocID = {
    type: String,
    default:'',
    trim: true
};
//批号
modelField.LotNumber = {
    type: String,
    trim: true
};
//物料
modelField.ItemMaster = {
    type: Schema.ObjectId,
    ref: 'ItemMaster',
    Name: '物料'
};
//入库人
modelField.RcvUser = {
    type: Schema.ObjectId,
    ref: 'User'
};
//入库时间
modelField.RcvDateTime = {
    type: Date,
    default: Date.now
};
//入库数量
modelField.RcvQty = {
    type: Number
};
//入库工序
modelField.RcvOperation = {
    type: Schema.ObjectId,
    ref: 'Operation'
};
//对应流水
modelField.BizRecord = {
    type: Schema.ObjectId,
    ref: 'BizRecord'
};
//待转区
modelField.WareHouse = {
    type: Schema.ObjectId,
    ref: 'WareHouse'
};
//容器
modelField.Container = {
    type: Schema.ObjectId,
    ref: 'Container'
};
//ERP MO.ID
modelField.ErpId = {
    type: String,
    trim: true
};

//begin-条码平台开发-jiaxy
//数据类型：0，智能工厂；1，条码平台
modelField.DataType = {
    type: Number,
    default: 0
};
//U9生单单据类型：
//0，收货单；1，委外收货单；2，出货单；3，调出单；4，调入单
//5，杂发单；6，杂收单；7，盘点单；8，领料单；完工入库单；
modelField.DocType = {
    type: Number,
    default: -1
};
//生单Json：
modelField.CreateDocJSON = {
    type: String,
    trim: true
};
modelField.CreateDocContextJSON ={
    type: String,
    trim: true
}

//已经生单
modelField.IsCreatedERPDoc = {
    type: Boolean
};
//企业号
modelField.EntCode={
    type: String,
    trim: true
};
//组织编码
modelField.OrgCode={
    type: String,
    trim: true
};
//异动类别： 0，收货； 1，发货
modelField.Direction={
    type:Number,
    default:0
};
//单据编码
modelField.DocCode={
    type: String,
    trim: true
};
//操作key:传Erp生单使用
modelField.OperationKey={
    type: String,
    trim: true
};

modelField.UserCode={
    type: String,
    trim: true
}

modelField.CultureName={
    type: String,
    trim: true
}

// 单号
modelField.DocNo={
    type: String,
    trim: true
}
//end-条码平台开发

var newModel = new Model(modelField);
newModel.addIndex({ItemMaster: 1, RcvBusinessType: 1});
newModel.create('RcvRecord', '入库记录');